﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CL2036.Protocol
{
    internal static class CL188
    {
        /// <summary>
        /// 类型参数
        /// </summary>
        private static byte m_routerData = 0;
        /// <summary>
        /// 开关参数
        /// </summary>
        private static byte m_isOpen = 0;

        /// <summary>
        /// 设置表位485通道开关
        /// </summary>
        /// <param name="Bwh">表位号</param>
        /// <param name="IsOpen">是否打开</param>
        /// <returns></returns>
        public static byte[] WcbSetup(int Bwh, bool IsOpen)
        {
            m_routerData = (byte)Bwh;
            m_isOpen = (byte)(IsOpen ? 1 : 0);
            return getFrameData();
        }
        /// <summary>
        /// 设置表位485通道开关
        /// </summary>
        /// <param name="WcbType">设置类型</param>
        /// <param name="IsOpen">是否打开</param>
        /// <returns></returns>
        public static byte[] WcbSetup(byte WcbType, bool IsOpen)
        {

            m_routerData = WcbType;
            m_isOpen = (byte)(IsOpen ? 1 : 0);

            return getFrameData();
        }

        /// <summary>
        /// 组帧
        /// </summary>
        /// <returns></returns>
        private static byte[] getFrameData()
        {
            byte[] bytData = new byte[] { 0xA3, 1, 1, 3, m_routerData, m_isOpen };
            return PublicFunction.CLT.GetFrameData(0x10, 0x80, bytData);
        }

    }
}
